package adapter;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

import controller.PasscodeFragment;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TwoLineListItem;


public class SettingAdapter extends ArrayAdapter<String[]>{

	private Context context = null;
	private List<String[]> mListItem = null;
	private int mResourceID = 0;
	public SettingAdapter(Context context,  List<String[]> objects) {
		super(context, android.R.layout.simple_list_item_2, objects);
		
		this.context = context;
		mListItem = objects;
		mResourceID = android.R.layout.simple_list_item_2;
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		TwoLineListItem row;
		if (convertView == null) {
			LayoutInflater inflater = (LayoutInflater) context
					.getApplicationContext()
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			row = (TwoLineListItem) inflater.inflate(
					this.mResourceID, null);
			row.getText1().setTextColor(Color.BLACK);
			row.getText2().setTextColor(Color.BLACK);
		} else {
			row = (TwoLineListItem) convertView;
		}
		String[] item = mListItem.get(position);

		if (item != null && Array.getLength(item) == 2) {
			row.getText1().setText(item[0]);
			row.getText2().setText(item[1]);
		}

		return row;
	}

}
